package com.grj.order.repository;

import com.grj.common.model.OrderOutbox;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author ganru
 * @date 2025/10/19 5:47
 */
@Repository
public interface OutboxRepository extends JpaRepository<OrderOutbox, Long> {
    @Modifying
    @Query("update OrderOutbox o set o.sent = true, o.sentAt = current_timestamp where o.id = :id")
    void markSent(Long id);

    List<OrderOutbox> findTop100BySentFalseOrderByCreatedAtAsc();
}